package com.atguigu.gulimall.order;

import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * 公：
 * MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8Wmf7eUiWEI4CCigWdE2rem2JhdA87Tf8aJ64aCEyB0WrAK9iTdX9HYby3RXSI+lRKQ4qzsHikjcTy+XpDKT3IEBecbiy3J93oMZC+9CjTEEFaOmFh8iS3YIIFbyNx74gFWcuU7/z5UWhp6Qmp4YECqy2TzXuqlJEs9Tx59i3XxES9dsRwGU7OYtrcgHUCtFKIbR+YOYg16/fsU+9fVQ2qOnptKIBU7hYTiEUU1rIaj4+GJJWLuw/6VPZjB+RxiV6vebRmH/xM0N3jG5oZEwSjRmGBfseBs5WdlyHAUnORJVz0rnVBh7xwg0iJtd3T3QZS/CNnjzf77DYfZ/N4iG5QIDAQAB
 * 私：
 * MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDxaZ/t5SJYQjgIKKBZ0Tat6bYmF0DztN/xonrhoITIHRasAr2JN1f0dhvLdFdIj6VEpDirOweKSNxPL5ekMpPcgQF5xuLLcn3egxkL70KNMQQVo6YWHyJLdgggVvI3HviAVZy5Tv/PlRaGnpCanhgQKrLZPNe6qUkSz1PHn2LdfERL12xHAZTs5i2tyAdQK0UohtH5g5iDXr9+xT719VDao6em0ogFTuFhOIRRTWshqPj4YklYu7D/pU9mMH5HGJXq95tGYf/EzQ3eMbmhkTBKNGYYF+x4GzlZ2XIcBSc5ElXPSudUGHvHCDSIm13dPdBlL8I2ePN/vsNh9n83iIblAgMBAAECggEAPAr1SAnxXNo7bWwNVcl/PAogz6CA+xxFhq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7hENV7kFjenCaRu79l4lWnenRajNwRfeHzwb1Yjgw5YCVnMFIm6tw34GzYgSiFNSmn2QvRTnq+nL6uZj5MurNRkg1iW3NsApPZeafyGU/Qg==
 * 支付宝 公：
 * MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8StbJx71FriOlAkS9ICh88e8EC9zLTPXdvQVpPuW2dnwoGPYzDAhDPFYfzhB9Rz+Bkf07S0DORJ6lh332+txZDsT4XK7zLd7O9pHB6VfsvG2WxsHAkWoc48N+1nes4bkdldJ639PXhPx0Xxw93uXfIeU0+cWk8fLZagq9h8FTgxW5o+rrjl8NnSr9CiCjurm+mFekvp8uUa9oOwrdW91HxENaX3qS02Bj4C11GDq+QtryYZ+8pJAWOJZvxZ2t1ftkpe10BhwtU7ZMTAxl9y+Cx4G6gO4aOIUbwgv2xArT62PyzRSMvgfCkDAmikKexQP5VNw4mhoqZjtPPuAF8/AywIDAQAB
 */

/**
 * 使用RabbitMQ
 * 应用amqp场景；RabbitAutoConfiguration就会自动生效
 * 1。导入pom
 *         <dependency>
 *             <groupId>org.springframework.boot</groupId>
 *             <artifactId>spring-boot-starter-amqp</artifactId>
 *         </dependency>
 * 2.给容器中自动配置了
 *      RabbitTemplate ，AmqpAdmin, CachingConnectionFactory,RabbitMessageingTemplate
 *      所有都属性都是在这里绑定的
 *      @ConfigurationProperties(prefix = "spring.rabbitmq")
 *
 * 3.在配置文件中配置
 *      spring.rabbitmq.host=192.168.2.200
 *      spring.rabbitmq.port=5672
 *      spring.rabbitmq.virtual-host=/ #虚拟主机
 * 4.开启功能使用
 *      @EnableRabbit @EableXxxxxx
 *
 * 5.监听消息
 *      使用@RabbitListener 必须有开启@EnableRabbit --可以在类或方法上 类+方法
 *      @RabbitHandler -- 只能标在方法上 方法
 *
 *      单一个消息发送类型不一样时，可以用RabbitHandler来标注重载来区分各种不同都消息，
 *      RabbitListener在类上来标明需要接收哪些队列都消息
 *
 * 6。本地事物失效问题:示例代码见：OrderServiceImpl中
 * 用一个对象内事物方法互调默认失效：
 *      原因：绕过类代理对象，事物使用代理对象来控制的
 *      解决：使用代理对象来调用事物方法
 *          1。引入aop-starter aop中帮我们引入了aspectjweaver
 *         <dependency>
 *             <groupId>org.springframework.boot</groupId>
 *             <artifactId>spring-boot-starter-aop</artifactId>
 *         </dependency>
 *         2.开启aspectjweaver动态代理功能,以后所有的动态代理都是aspectj创建的，（即使没有接口，也能创建代理）
 *          @EnableAspectJAutoProxy(exposeProxy = true)
 *        3。对外暴露代理对象
 *          exposeProxy = true
 *        4。获取代理对象，使用代理对象调用方法
 *         OrderServiceImpl orderService = (OrderServiceImpl) AopContext.currentProxy();
 *         orderService.b();
 *         orderService.c();
 *
 * 7.Seata控制分布式事物
 *  http://seata.io/en-us/docs/user/quickstart.html
 *  1。每个微服务先必须创建undo_log表
 *  2。安装事物协调器 https://github.com/seata/seata/releases
 *  3。整合
 *      1。导入依赖
 *  	<dependency>
 * 			<groupId>com.alibaba.cloud</groupId>
 * 			<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
 * 		</dependency>
 *      seata-all-0.7.1
 *      2。解压并启动seata-server
 *          register-config:注册中心配置
 *          register下： 注册中心
 *              type指定注册中心类型
 *              到对应类型下配置注册中心地址
 *          config下：   配置中心
 *              type：file.conf
 *
 *      4。所有想要用到分布式事物都微服务，都需要使用seata DataSourceProxy代理自己的数据源
 *          配置代理数据源 MySeataConfig
 *      5。每个微服务都必须导入file.conf 和 registry.conf
 *          file.conf 的 service.vgroup_mapping 配置必须和spring.application.name一致
 *          默认会使用 ${spring.application.name}-fescar-service-group作为服务名注册到 Seata Server上
 *          也可以通过配置 spring.cloud.alibaba.seata.tx-service-group修改后缀，但是必须和file.conf中的配置保持一致
 *
 *      3。开启全局事物：
 *          在大事物的入口启用全局事物@GlobalTransactional
 *          在每个远程小事物的入口使用@Transactional
 */
@EnableRabbit
@EnableAspectJAutoProxy(exposeProxy = true)
@EnableFeignClients
@EnableRedisHttpSession
@EnableDiscoveryClient
@SpringBootApplication
public class GulimallOrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(GulimallOrderApplication.class, args);
    }

}
